import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 0
 * Date: 2023-03-19
 * Time: 21:38
 */
class Student {

    private String name = "88888";
    private int age;
    public static String classRoom = "208";

    /*static {
        classRoom = "201";
        System.out.println("静态代码块！");
    }*/

    /*static {
        fsdfafsa
    }

    static {
        classRoom = "201";
        System.out.println("静态代码块！");
        fsdfafsa
    }*/


    /*{
        this.name = "zhangsan";
        System.out.println("构造块！");
    }*/

    public Student() {
        System.out.println("调用不带参数的构造方法！");
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("调用了带2个参数的构造方法！");
    }





    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void print() {
        System.out.println("姓名"+name+" 年龄："+age);
    }

    //学完多态之后 就能够明白！！！-》 当自己也重新写了这个方法之后，会掉自己的！！ 为什么？先等等
    /*public String toString() {
        return "姓名: "+name+" 年龄："+age;
    }*/

    @Override
    public String toString() {
        return "Student{" +
                "姓名='" + name + '\'' +
                ", 年龄=" + age +
                '}';
    }
}
public class Test {
    public static void main(String[] args) {
        //System.out.println(Student.classRoom);
        Student student1 = new Student("张三",10);
        //student1.print();
        System.out.println(student1);

        System.out.println("=====");
        //Student student2 = new Student();
        //System.out.println(student.getName());
    }
}
 +21 J20230919/src/demo1/Test3.java 0 → 100644
         package demo1;

         import demo2.Test1;

/**
 * @Author 12629
 * @Description：
 */
public class Test3 extends Test1 {

    public void func() {
        System.out.println(super.a);
    }

    public static void main(String[] args) {
        //Test1 test1 = new Test1();
        Test3 test3 = new Test3();
        test3.func();
        //System.out.println(test1.a);
    }
}